package top.wfzzq.dp.factory;

import javax.sql.rowset.BaseRowSet;

/**
 * 演示类
 * 
 * @author wanghui
 *
 */
public class Demo {
	public static void main(String[] args) {
		// 佚名
		// ITeacher teacher = new JavaTeacher();
		// teacher.teach();
		// teacher=new JavaTeacher("胡辉煜");
		// teacher.teach();
		// teacher=new PythonTeacher("李嘉誠");
		// teacher.teach();
		// 通過工廠方法創建對象,不直接创建类型
		//可以掩蓋具體的實現類型，方法系統扩展
		ITeacher teacher = Boss.zhaopin("java");
		teacher.setName("工厂方法");
		teacher.teach();
		System.out.println(teacher.getClass());
		teacher = Boss.zhaopin("python");
		teacher.teach();
		System.out.println(teacher.getClass());
		//===========================================
		ITeacher t1=Boss.zhaopin("java");
		System.out.println(t1.getClass());
		ITeacher t2=Boss.zhaopin("java");
		System.out.println(t2.getClass());
		System.out.println(t1==t2);
		System.out.println("单例模式的工厂方法==========="+(t1==t2));
		ITeacher t3=Boss.szhaopin("java");
		ITeacher t4=Boss.szhaopin("java");
		ITeacher t5=Boss.szhaopin("python");
		ITeacher t6=Boss.szhaopin("python");
		System.out.println("同类型的是否单例："+(t3==t4));
		System.out.println("不同类型的是否单例："+(t3==t5));
		System.out.println("同类型的是否单例："+(t3==t6));
		//========================================
	
	    teacher.setName("pythoner");
	    teacher.teach();
		System.out.println(teacher.getClass());
		ITeacher t7 = Boss.zhaopin("web");
		System.out.println("同类型的是否单例:" + (t3 == t7));
	}
}